<script type="text/javascript">
    $(function() {
        $("#theTable.tiga tr:even").addClass("stripe1");
        $("#theTable.tiga tr:odd").addClass("stripe2");

        $("#theTable.tiga tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });
    
    (function() {
        $("#theTable tr:even").addClass("stripe1");
        $("#theTable tr:odd").addClass("stripe2");

        $("#theTable tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });
    
    $(document).ready(function() {

        $('table#theTable.tiga').each(function() {
            var currentPage = 0;
            var numPerPage = 10;
            var $table = $(this);
            $table.bind('repaginate', function() {
                $table.find('tbody tr').hide().slice(currentPage * numPerPage, (currentPage + 1) * numPerPage).show();
            });
            $table.trigger('repaginate');
            var numRows = $table.find('tbody tr').length;
            var numPages = Math.ceil(numRows / numPerPage);
            var $pager = $('<div class="pager"></div>');
            for (var page = 0; page < numPages; page++) {
                $('<span class="page-number"></span>').text(page + 1).bind('click', {
                    newPage: page
                }, function(event) {
                    currentPage = event.data['newPage'];
                    $table.trigger('repaginate');
                    $(this).addClass('active').siblings().removeClass('active');
                }).appendTo($pager).addClass('clickable');
            }
            $pager.insertAfter($table).find('span.page-number:first').addClass('active');
        });

    });

</script>

<?php
// www.contoh-ta.com
//author : asep setiawan & Team
ini_set('display_errors', 1);
ini_set('error_reporting', E_ERROR);
include '../../inc/inc.koneksi.php';

$cari = $_POST['cari'];
$where = " WHERE noinduk LIKE '%$cari%' OR nama LIKE '%$cari%'";

$table = "";
$table .= "<table id='theTable' class='tiga' width='100%'>";
$table .= "<thead>";
$table .= "<tr>";
$table .= "<th width='5%'>No</th>";
$table .= "<th>No Induk</th>";
$table .= "<th>Nama</th>";
$table .= "<th>L/P</th>";
$table .= "<th>Banyaknya Pembayaran</th>";
$table .= "<th>Sisa Tunggakan</th>";
$table .= "<th>Details</th>";
$table .= "</tr>";
$table .= "</thead>";
$table .= "<tbody>";

$sql = "";
$sql .= " SELECT a.noinduk,a.nama,a.jenis_kelamin, ";
$sql .= " (SELECT count(jumlah) FROM spp WHERE noinduk=a.noinduk) as total ";
$sql .= " FROM siswa as a ";
$sql .= $where;
$sql .= " ORDER BY noinduk ";

$query = mysql_query($sql);
$rows = mysql_num_rows($query);
$no = 1;
while ($result = mysql_fetch_array($query)) {
    $table .= "<tr>";
    $table .= "<td align='center'>$no</td>";
    $table .= "<td align='center'>$result[noinduk]</td>";
    $table .= "<td>$result[nama]</td>";
    $table .= "<td align='center'>$result[jenis_kelamin]</td>";
    $table .= "<td align='right'><b>" . number_format($result[total]) . " Kali</b></td>";
    $table .= "<td align='right'><b>" . number_format(12 - $result[total]) . " Kali</b></td>";
    $table .= "<td align='center'>";
    $table .= "<a href='media.php?module=simpanan&id=$result[noinduk]'>View</a>";
    $table .= "</td>";
    $table .= "</tr>";
    
    $no++;
}
$table .= "</tbody>";
$table .= "</table>";

if ($rows > 0) {
    echo $table;
} else {
    echo '';
}

?>